<template>
	<view>
		<div id="app">
			<div class="top">
				<div class="top_logo">
					<img src="https://shop.zdsy.shop/themes/screens/public/assets/images/follow.png">
					</div>
				<div class="top_title">
					<div class="pay_way">卡密充值</div>
				</div>
			</div>
			<div class="pay_money">
				<div>输入卡号</div>
				<div class="money_num">
					<input type="text" v-model="card_id" v-autofocus autofocus="autofocus" ref="num_input"
						placeholder="请输入卡号">
					<!-- <img src="__TMPL__/public/assets/images/clear.png" @click="clear()"> -->
				</div>
			</div>
			<div class="pay_money">
				<div>输入卡密</div>
				<div class="money_num">

					<input type="text" v-model="password" v-autofocus autofocus="autofocus" ref="num_input"
						placeholder="请输入密码">
		 		<!-- <img src="__TMPL__/public/assets/images/clear.png" @click="clear()"> -->
				</div>
			</div>


			<div class="btn" @click="scan_submit()">点击充值</div>
		</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				card_id:'',
				password:''
			};
		},
		onLoad(options) {

		},
		methods: {
			showDiv() {
				this.userFeedbackHidden = false
			},
			hideDiv() {
				this.userFeedbackHidden = true
			},
			scan_submit() {
				if (!this.card_id) {
				
					alert("卡号不能为空!");
				
					return false;
				}
				
				if (!this.password) {
				
					alert("密码不能为空!");
				
					return false;
				}

				this.$api.post({
					url: "portal/store/userRecharge",
					data: {
						card_id: this.card_id,
						password: this.password
					},
					success: function(res) {
						// console.log(res);
						// order_id = res.order_id;
						if (res.code == 1) {
							
							uni.switchTab({
							   url: '/pages/my/user/user',
							   success: function(e) {
							     var page = getCurrentPages().pop();
							     if (page == undefined || page == null) return;
							     page.onLoad();
							   }
							 })


						} else {
							alert(res.msg);
						}
					},
					error: function(request) {
						alert("服务器繁忙!");
						return;
					},
				});
			},
		}
	};
</script>

<style>
	html,
	body {
		width: 100%;
		/* height: 100%; */
		background: #F2F2F2;
	}

	.dispalyFlex {
		display: flex;
		align-items: center;
	}

	.flex {
		flex: 1;
	}

	.top {
		margin: 2rem 0.5rem;
		padding-top: 0rem;
		display: flex;
		align-items: center;
	}

	.top_logo img{
		width: 3rem;
		height: 3rem;
		margin: 0 1rem;
	}

	.top_title {
		/* margin-top: 1.25rem; */
		text-align: left;
	}

	.pay_money {
		padding: 0 2rem;
		/* padding-bottom: 1.25rem;
        border-bottom: 0.25rem solid #f5f5f5; */
		display: flex;
		align-items: center;
		border-radius: 0.4rem;
		background-color: #fff;
		margin: 1rem 1rem;
		padding: 0.8rem 0.5rem;
	}

	.money_num {
		position: relative;
		display: flex;
		justify-content: flex-end;
		flex: 1;
		align-items: center;
	}

	.pay_money input {
		width: 82%;
		display: inline-block;
	}

	.pay_money img {
		width: 1rem;
		height: 1rem;
		position: absolute;
		right: 0;
		top: 0.5rem;
		z-index: 999;
	}

	.bottom {
		margin: 1.25rem 2rem 3rem 2rem;
	}

	.btn {
		text-align: center;
		color: #fff;
		background-color: #df2e24;
		padding: 0.5rem;
		margin: 0 2rem;
		border-radius: 0.2rem;
		margin-top: 2rem;
	}

	.aui-radio:checked,
	.aui-radio.aui-checked,
	.aui-checkbox:checked,
	.aui-checkbox.aui-checked {
		background-color: #FF9A32;
		border: solid 1px #FF9A32;
		text-align: center;
		background-clip: padding-box;
	}

	.weui-cell {
		padding: 0;
	}

	.font-14 {
		padding: 0.5rem 0;
	}

	.pay_way {
		font-size: 0.6rem;
		color: red;
		margin-top: 0.2rem;
	}
</style>
